public class AccountExtensionController{

    private ApexPages.StandardController controller;
    public Account acct {get; set;}
    public String retURL {get; set;}
    public String rType {get; set;} 
    public String cancelURL {get; set;}
    public String ent {get; set;}
    
      
    private String getRecordTypeId(){
        Map <String,Schema.RecordTypeInfo> recordTypes = Account.sObjectType.getDescribe().getRecordTypeInfosByName();
    
        //Get the record type id of from the Map based on the Name    
        Id RecTypeId = recordTypes.get('Account Request').getRecordTypeId();
        return  (String)RecTypeId ;
    }
        
    public AccountExtensionController(ApexPages.StandardController controller) {    
        this.controller = controller;
        this.acct = (Account)controller.getRecord();
        
     
        rType = ApexPages.currentPage().getParameters().get('RecordType');
       // rTypeName = getRecordTypeName();
        
        if(getRecordTypeId().contains(rType)){
            retURL = '/apex/Account_Request_Success';
        }
        else
        {
            retURL = ApexPages.currentPage().getParameters().get('retURL');
        }
        //retURL = getRecordTypeId();
        cancelURL = ApexPages.currentPage().getParameters().get('cancelURL');
        ent = ApexPages.currentPage().getParameters().get('ent');           
    }
    
    public Pagereference initialize(){
        PageReference returnURL;
              
        returnURL = new PageReference('/001/e?');
             
        returnURL.getParameters().put('saveURL', retURL);     
        returnURL.getParameters().put('RecordType', rType);
        returnURL.getParameters().put('cancelURL', cancelURL);
        returnURL.getParameters().put('ent', ent);   
        returnURL.getParameters().put('nooverride', '1');
                    
        returnURL.setRedirect(true);
        
        return returnURL;
    }
  
}